package com.ziytek.web.citizen.enums;

import com.ziytek.web.citizen.service.itf.StepAddResponse;
import lombok.Getter;

/**
 * @author fenghx
 * @version v1.0
 * @className ResponseEnum
 * @descripton 返回码枚举
 * @date 2024/3/11 18:11
 **/

@Getter
public enum ResponseEnum implements StepAddResponse {
    /**
     * 枚举
     **/

    SUCCESS("0", "成功"),
    ERROR_START("20", "异常开头"),
    PARAMETER_ERROR("201", "参数错误"),
    USER_NOT_EXIST("202", "用户不存在"),
    PASSWORD_ERROR("203", "密码错误"),
    OBJECT_NOT_EXIST("204", "对象不存在"),

    OTHER("900", "接口请求失败"),
    ROLE_ADMIN("admin", "admin"),
    ROLE_USER("user", "role"),
    NO_PERMISSION("988", "非管理员没有操作权限"),

    OTHER_ERROR("800", "其他");


    private final String code;
    private final String desc;

    ResponseEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public String getMsg(String code) {
        for (ResponseEnum sp : ResponseEnum.values()) {
            if (sp.getCode().equalsIgnoreCase(code)) {
                return sp.desc;
            }
        }
        return OTHER_ERROR.getDesc();
    }

    @Override
    public int getPosition(String code) {
        return 0;
    }
    @Override
    public String getCode(String line, int position) {
        return null;
    }
}